//全局过滤器

//过滤年月日  时分秒
export function formatYMDhms(date) {
    let time = new Date(date)
  
    let Y = time.getFullYear()
    let M = time.getMonth() + 1
    let D = time.getDate()
  
    let h = time.getHours()
    let m = time.getMinutes()
    let s = time.getSeconds()
  
    let YMD = [Y, M, D].map(v => String(v).padStart(2, '0')).join('-')
  
    let hms = [h, m, s].map(v => String(v).padStart(2, '0')).join(':')
  
    return YMD + ' ' + hms
  }
  
  export function formatYMD(date) {
    let time = new Date(date)
  
    let Y = time.getFullYear()
    let M = time.getMonth() + 1
    let D = time.getDate()
  
    let h = time.getHours()
    let m = time.getMinutes()
    let s = time.getSeconds()
  
    let YMD = [Y, M, D].map(v => String(v).padStart(2, '0')).join('-')
  
    let hms = [h, m, s].map(v => String(v).padStart(2, '0')).join(':')
  
    return YMD
  }
  
  export function formatHms(date) {
    let time = new Date(date)
  
    let Y = time.getFullYear()
    let M = time.getMonth() + 1
    let D = time.getDate()
  
    let h = time.getHours()
    let m = time.getMinutes()
    let s = time.getSeconds()
  
    let hms = [h, m, s].map(v => String(v).padStart(2, '0')).join(':')
  
    return hms
  }


  // 处理金额格式
  export function formatMoney(Money){
    return String(Money).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
  }

  export function toFixed2(v, format = 2) {
    return v.toFixed(format);
  }